import grails.test.*

class TagTests extends GrailsUnitTestCase {
  def tags = []
  def masters = []
  def mastertags = []
  def yearTag

  protected void setUp() {
    super.setUp()
        
    def t = new Tag()
    yearTag = t

    t.name = "2009"
    t.tagType = 0
    t.save()
    tags.add(t)

    def t2 = new Tag()
    t2.name = "8"
    t2.tagType = 1
    t2.save()
    tags.add(t2)

    def m = new Master()
    m.checksum = "1010101"
    m.comment = ""
    m.created = new Date()
    m.uploaded = new Date()
    m.fileName = "foo.jpg"
    m.fileSize = 100000
    m.imageHeight = 600
    m.imageWidth = 800
    m.isPublic = false
    m.relativePath = "relative"
    m.save()
    masters.add(m)

    def mt = new MasterTag()
    mt.masterId = m.id
    mt.tagId = t.id
    mt.save()
    mastertags.add(mt)

    mt = new MasterTag()
    mt.masterId = m.id
    mt.tagId = t2.id
    mt.save()
    mastertags.add(mt)
  }

  protected void tearDown() {
    super.tearDown()
    for(Tag t in tags) {
      t.delete()
    }

    for(Master m in masters) {
      m.delete()
    }

    for(MasterTag mt in mastertags) {
      mt.delete()
    }
  }

  void testSomething() {
    Tag.getMonthTagsForYear(yearTag)
  }
}
